package  com.pcbly.web.business.crm;

/**
* @author carl.song
* Copyright (c) 2010 Lightsoft, International.
* All rights reserved.
*
*/

import java.util.HashMap;
import java.util.List;

import com.pcbly.web.persistence.crm.LsthdProductDao;
import com.pcbly.web.persistence.table.ColumnDao;
import com.pcbly.web.bean.crm.LsthdProductBean;
import com.pcbly.web.bean.table.ColumnBean;
import com.pcbly.web.business.BaseServiceImp;
import com.pcbly.web.components.hibernate.support.Page;
import com.pcbly.web.components.form.AbstractAnalyseCommonDataExt;
import com.pcbly.web.components.form.AnalyseCommonDataExtCreate;
import com.pcbly.web.components.form.AnalyseCommonDataExtEdit;
import com.pcbly.web.components.form.AnalyseCommonDataExtView;

 
public class LsthdProductServiceImp extends BaseServiceImp<LsthdProductBean> implements LsthdProductService {
	 public LsthdProductServiceImp() {
		super();
		// TODO Auto-generated constructor stub
	}
	private LsthdProductDao lsthdProductDao;
	
	private ColumnDao columnDao;

	public void setColumnDao(ColumnDao columnDao) {
		this.columnDao = columnDao;
	}
	
	public void setLsthdProductDao(LsthdProductDao lsthdProductDao) {
		this.lsthdProductDao = lsthdProductDao;
	}
	
	@Override
	public LsthdProductBean getLsthdProductBeanById(String id) throws Exception {
		// TODO Auto-generated method stub
		return lsthdProductDao.get(LsthdProductBean.class,id);
	}
	
	@Override
	public void removeLsthdProductBeanById(String id) throws Exception{
		lsthdProductDao.removeLsthdProductBeanById(id);
	}
	
	@Override
	public void removeLsthdProductBeanByIds(String ids) throws Exception{
		lsthdProductDao.removeLsthdProductBeanByIds(ids);
	}
	
	
	@Override
	public LsthdProductBean saveLsthdProductBean(LsthdProductBean crm) throws Exception{
		return lsthdProductDao.saveLsthdProductBean(crm);
	}
	
	@Override
	public LsthdProductBean updateLsthdProductBean(LsthdProductBean crm) throws Exception{
		lsthdProductDao.saveObject( crm);
		return crm;
	}
	public Page<LsthdProductBean>  findLsthdProductBeanByCond(LsthdProductBean bean,
			Page<LsthdProductBean> page, String orderByName, boolean asc)
			throws Exception{
		return lsthdProductDao.findLsthdProductBeanByCond(
				bean, page, orderByName, asc);
	}
	
	@Override
	public String findLsthdProductBeanExtCreate(String tableName) throws Exception {
		// TODO Auto-generated method stub
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtCreate();
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public String findLsthdProductBeanExtEdit(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		List<HashMap<String, String>> dataList = lsthdProductDao
				.findCommnonDataBeanExt(tableName, id);
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtEdit();
		common.setDataList(dataList);
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public String findLsthdProductBeanExtView(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		List<HashMap<String, String>> dataList = lsthdProductDao
				.findCommnonDataBeanExt(tableName, id);
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtView();
		common.setDataList(dataList);
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public void saveLsthdProductBeanExt(String sql) throws Exception {
		// TODO Auto-generated method stub
		lsthdProductDao.saveCommnonDataBeanExt(sql);
	}

	@Override
	public boolean getHasLsthdProductBeanExtData(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		return lsthdProductDao.getHasCommnonDataBeanExt(tableName, id);
	}
}
